<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {

    // Temp Dir bekannt machen

    protected function _initTMP() {
        $_SERVER['TEMP'] = realpath(dirname(__FILE__) . '/tmp');
    }

    // ZendX fuer jQuery

    protected function _initZendX() {

        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper');
    }

    // html Header befuellen

    protected function _initHeader() {
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->headTitle('Scoring')
                ->setSeparator(' - ')
                ->setDefaultAttachOrder(Zend_View_Helper_Placeholder_Container::PREPEND);
        $view->headLink()
                ->prependStylesheet('/resources/css/default.css')
                ->appendStylesheet('/resources/css/font-awesome.css')
                ->appendStylesheet('/resources/jscript/chosen/chosen.css')

                //->appendStylesheet('/resources/css/dark-hive/jquery-ui-1.8.17.custom.css');
                ->appendStylesheet('/resources/jscript/chosen/chosen.css')
                ->appendStylesheet('/resources/css/dark-hive/jquery-ui-1.8.17.custom.css');
    }

    protected function _initPartial() {
        $this->bootstrap('view');
        $view = $this->getResource('view');

        $view->partial()->setObjectKey('model');
        $view->partialLoop()->setObjectKey('model');
    }

    // Routen fuer die statischen Seiten abkuerzen


    public function _initRoutes() {
        $frontController = Zend_Controller_Front::getInstance();
        $router = $frontController->getRouter();


        $route = new Zend_Controller_Router_Route_Static(
                        'about',
                        array('controller' => 'Static', 'action' => 'about')
        );

        $router->addRoute('about', $route);

        $route = new Zend_Controller_Router_Route_Static(
                        'faq',
                        array('controller' => 'Static', 'action' => 'faq')
        );

        $router->addRoute('faq', $route);


        $route = new Zend_Controller_Router_Route(
                        'backdoor/user/:user/:action/*',
                        array(
                            'module' => 'backdoor',
                            'controller' => 'user',
                            'action' => 'index',
                            'user' => '&lt;keine Angabe&gt;'
                        )
        );
        $router->addRoute('user', $route);

        $route = new Zend_Controller_Router_Route(
                        'backdoor/user/create',
                        array(
                            'module' => 'backdoor',
                            'controller' => 'user',
                            'action' => 'create'
                        )
        );
        $router->addRoute('create', $route);
    }

    // Ubersetzungs-Objekt initialisieren. Abgeschaut bei http://www.codeforest.net/multilanguage-support-in-zend-framework

    protected function _initTranslate() {

        $locale = new Zend_Locale();
        if ($locale->getLanguage() == 'de') {

            $translate = new Zend_Translate(
                            array(
                                'adapter' => 'gettext',
                                'content' => APPLICATION_PATH . '/languages/german.mo',
                                'locale' => 'de'
                            )
            );
            $registry = Zend_Registry::getInstance();
            $registry->set('Zend_Translate', $translate);
            $translate->setLocale('de');
            Zend_Form::setDefaultTranslator($translate);
        }
    }

    /*
     * ZF DEBUG dazuladen - riss den Firefox zu oft in den Abgrund
     * 
      protected function _initZFDebug() {
      $autoloader = Zend_Loader_Autoloader::getInstance();
      $autoloader->registerNamespace('ZFDebug');

      $options = array(
      'plugins' => array('Variables',
      'File' => array('base_path' => APPLICATION_PATH),
      'Memory',
      'Time',
      'Registry',
      'Exception')
      );

      # Instantiate the database adapter and setup the plugin.
      # Alternatively just add the plugin like above and rely on the autodiscovery feature.
      if ($this->hasPluginResource('db')) {
      $this->bootstrap('db');
      $db = $this->getPluginResource('db')->getDbAdapter();
      $options['plugins']['Database']['adapter'] = $db;
      }

      # Setup the cache plugin
      if ($this->hasPluginResource('cache')) {
      $this->bootstrap('cache');
      $cache = $this - getPluginResource('cache')->getDbAdapter();
      $options['plugins']['Cache']['backend'] = $cache->getBackend();
      }

      $debug = new ZFDebug_Controller_Plugin_Debug($options);

      $this->bootstrap('frontController');
      $frontController = $this->getResource('frontController');
      $frontController->registerPlugin($debug);
      }
     */
}
